package cn.hamster3.mc.plugin.core.bukkit.command.lore;

import cn.hamster3.mc.plugin.core.bukkit.HamsterCorePlugin;
import cn.hamster3.mc.plugin.core.bukkit.command.ParentCommand;
import cn.hamster3.mc.plugin.core.bukkit.command.lore.sub.*;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;

public final class LoreCommand extends ParentCommand {
    public static final LoreCommand INSTANCE = new LoreCommand();

    public LoreCommand() {
        addChildCommand(LoreAddCommand.INSTANCE);
        addChildCommand(LoreRemoveCommand.INSTANCE);
        addChildCommand(LoreSetCommand.INSTANCE);
        addChildCommand(LoreClearCommand.INSTANCE);
        addChildCommand(LoreNameCommand.INSTANCE);
        addChildCommand(LoreCustomModelDataCommand.INSTANCE);
        addChildCommand(LoreFlagCommand.INSTANCE);
        addChildCommand(LoreInfoCommand.INSTANCE);
        addChildCommand(LoreInsertCommand.INSTANCE);
    }

    @Override
    public @NotNull String getName() {
        return "hamster-lore";
    }

    @Override
    public @NotNull JavaPlugin getPlugin() {
        return HamsterCorePlugin.getInstance();
    }

    @Override
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
        for (int i = 0; i < args.length; i++) {
            args[i] = args[i].replace("&", "§");
            args[i] = args[i].replace("\\s", " ");
        }
        return super.onCommand(sender, command, label, args);
    }
}
